Skip to content

Feature: Installed node modules / Additional Info #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Nov 4, 2015

Conversation

frankebersoll
Copy link
Contributor

Somehow, I managed to corrupt the other pull request, so here is a new one:

This feature (Issue #6) adds a NodeModuleCollector.ts that tries to find all currently loaded npm modules:

  1. It synchronously runs npm ls --depth=0 --json to get all installed packages on root level. Those modules are cached, as they won't change during runtime.
  2. It checks require.cache to get all currently cached modules. Those are all JavaScript files that have been required since startup of the application.
  3. It crops all those paths to get the portion behind /node_modules/, which is the module name, and makes them unique.
  4. It returns all installed packages from 1. that match those module names.

Furthermore, it iterates all exception properties and puts them in the @ext data field on the error object, showing them as "Additional Data" in the UI (Issue #8). The following properties are currently ignored:

'arguments',
'column',
'columnNumber',
'description',
'fileName',
'message',
'name',
'number',
'line',
'lineNumber',
'opera#sourceloc',
'sourceURL',
'stack',
'stacktrace'


private getAdditionalData(exception: Error): { [key: string]: any } {
let keys = Object.keys(exception)
.filter(key => this.ignoredProperties.indexOf(key) < 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to check to see if the property is a function here.

@niemyjski
Copy link
Member

Looks great! I just noticed a use case where the extended data item could be added if any extra properties were functions (which would then return an empty object). If you want I can make this change.

@frankebersoll
Copy link
Contributor Author

@niemyjski Thanks for your review; just made some enhancements and added more unit tests, that should do the trick. Empty extended data won't be added now.

@frankebersoll frankebersoll force-pushed the feature/additionalInfo branch from 1621ee5 to b633648 Compare November 1, 2015 14:47
@niemyjski
Copy link
Member

Great job! I was thinking about this more this morning and I think that once we get our changes to parse depth and exclusions be generic.. We could come back to this and use that for parsing additional properties (share more code).

niemyjski added a commit that referenced this pull request Nov 4, 2015
Feature: Installed node modules / Additional Info
@niemyjski niemyjski merged commit 556848f into master Nov 4, 2015
@niemyjski niemyjski deleted the feature/additionalInfo branch November 4, 2015 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants